﻿using UnityEngine;
using System.Collections;
using Asset.Script.Core;

namespace Asset.Script.Update
{
    public class UpdateConfig : Singleton<UpdateConfig>
    {
        public string ResServerRoot;
        public string VersionCodeUrl;
        public string MD5Url;
        public string LocalVersionCodePath;
        public string LocaliOSPendingFilePath;
        public string LocalQQPendingFilePath;
        public string VersionFileName = "Version.pig";
        public string iOSPendingFileName = "iOSPendingFileName.txt";
        public string qqPendingFileName = "qqPendingFileName.txt";

        public string ResServerUrl = "";
        //这里实际放了很多内容，所有的config配置都在这里面，格式为json
        public string LoginServerUrl = "";
        //安卓下载地址
        public string androidDownUrl = "";
        //苹果下载地址
        public string iosDownUrl = "";

        public int loadingTime = 0;


        public UpdateConfig()
        {
            
        }

        public void UpdateUrl()
        {
            //Debug.Log("ResServerUrl:" + ResServerUrl);
            ResServerRoot = ResPathHelper.Instance.SeverFilePath(ResServerUrl + "/2_0");
            VersionCodeUrl = ResServerRoot + "/" + VersionFileName;
            MD5Url = ResServerRoot + "/md5.txt";
            LocalVersionCodePath = ResPathHelper.Instance.LocalFilePath() + "/" + VersionFileName;
            LocaliOSPendingFilePath = ResPathHelper.Instance.LocalFilePath() + "/" + iOSPendingFileName;
            LocalQQPendingFilePath = ResPathHelper.Instance.LocalFilePath() + "/" + qqPendingFileName;
        }

        public string GetSmallVersion()
        {
            return CheckVersion.Instance.LocalVersion();
        }

        public bool LocaliOSPendingState()
        {
            return CheckVersion.Instance.LocaliOSPendingState();
        }

        public bool LocalQQPendingState()
        {
            return CheckVersion.Instance.LocalQQPendingState();
        }
    }
}